<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>表信息</title>
    <link rel="stylesheet" href="/bus/js/css/layui.css" media="all">
    <link rel="stylesheet" href="/bus/upDataMain/style.css?t=1617720346170" media="all">
    <style>
        .my-inline3 {
            width: 150px
        }

    </style>
</head>
<body>
<forms class="layui-form">
    <div class="searchTable">
        搜索：
        <div class="layui-inline my-inline3">
            <input class="layui-input" name="tableId" id="tableId" placeholder="tableId" th:value="${genTable?.tableId}" value="1" autocomplete="off">
        </div>

        <button class="layui-btn mySubmitBtn" lay-filter="mySubmitBtn" id="mySubmitBtn" data-type="reload">搜索</button>
    </div>
</forms>


<div class="layui-tab layui-tab-brief" lay-filter="mytab">
    <ul class="layui-tab-title">
        <li class="layui-this">字段信息</li>
        <li>表信息</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <table class="" id="gtlist" lay-filter="gtlist"></table>
        </div>

        <div class="layui-tab-item">
            <div id="pageDemo"></div>

            <forms class="layui-form" action="">


                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>基本信息</legend>
                </fieldset>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">表名称</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="tableName" name="tableName" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">实体类名称</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="className" name="className" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">作者</label>
                        <div class="layui-input-inline">
                            <input type="text" id="functionAuthor" name="functionAuthor" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">表描述</label>
                        <div class="layui-input-block">
                            <textarea id="tableComment" name="tableComment" placeholder="请输入内容"
                                      class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>


                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>生成信息</legend>
                </fieldset>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">生成包路径</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="packageName" name="packageName" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">生成模块名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="moduleName" name="moduleName" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">生成业务名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="businessName" name="businessName" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">生成功能名</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="functionName" name="functionName" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">去除表前缀</label>
                        <div class="layui-input-inline">
                            <input type="text" id="tablePrefix" name="tablePrefix" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">模板组</label>
                        <div class="layui-input-inline">
                            <input type="text" id="gid" name="gid" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>

                </div>

                <button class="layui-btn submitBtnTable" lay-filter="submitBtnTable" id="submitBtnTable"
                        data-type="reload">提交
                </button>
            </forms>
        </div>
    </div>
</div>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="more">更多 <i class="layui-icon layui-icon-down"></i></a>
</script>

<script type="text/html" id="switchTpl-isRequired">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="isRequired" value="{{d.columnId}}" lay-skin="switch" lay-text="是|否"
           lay-filter="switchTpl-isRequired" {{ d.isRequired== 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="switchTpl-isInsert">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="isInsert" value="{{d.columnId}}" lay-skin="switch" lay-text="是|否"
           lay-filter="switchTpl-isRequired" {{ d.isInsert== 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="switchTpl-isEdit">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="isEdit" value="{{d.columnId}}" lay-skin="switch" lay-text="是|否"
           lay-filter="switchTpl-isRequired" {{ d.isEdit== 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="switchTpl-isList">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="isList" value="{{d.columnId}}" lay-skin="switch" lay-text="是|否"
           lay-filter="switchTpl-isRequired" {{ d.isList== 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="switchTpl-isQuery">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="isQuery" value="{{d.columnId}}" lay-skin="switch" lay-text="是|否"
           lay-filter="switchTpl-isRequired" {{ d.isQuery== 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="checkboxTpl">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="lock" value="{{d.id}}" title="锁定" lay-filter="lockDemo" {{ d.id== 10006
           ? 'checked' : '' }}>
</script>


<script type="text/html" id="selectSearch">
    <select class="selectFieldTypeClass" name="htmlType" value="{{d.columnId}}" title="数据字典" lay-filter="dictType"
            data-value="{{d.htmlType}}">
        <!--<option value="">[[#{table.select.option}]]</option>-->
        <option value="input" selected="">文本框</option>
        <option value="textarea">文本域</option>
        <option value="select">下拉框</option>
        <option value="radio">单选框</option>
        <option value="checkbox">复选框</option>
        <option value="summernote">富文本</option>
        <option value="datetime">日期控件</option>
        <option value="upload">上传控件</option>
    </select>
</script>

<script type="text/html" id="selectDict">
    <select class="selectFieldTypeClass" name="dictType" value="{{d.columnId}}" title="数据字典" lay-filter="dictType"
            data-value="{{d.dictType}}">
        <!--<option value="">[[#{table.select.option}]]</option>-->

        <option th:each="dict : ${dicts}" th:text="${dict.getDictType()}" th:value="${dict.getDictType()}"></option>
    </select>
</script>

<script type="text/html" id="selectQuery">
    <select class="selectFieldTypeClass" name="queryType" value="{{d.columnId}}" title="数据字典" lay-filter="dictType"
            data-value="{{d.queryType}}">
        <!--<option value="">[[#{table.select.option}]]</option>-->
        <option value="EQ">=</option>
        <option value="NE">!=</option>
        <option value="GT">&gt;</option>
        <option value="GTE">&gt;=</option>
        <option value="LT">&lt;</option>
        <option value="LTE">&lt;=</option>
        <option value="LIKE" selected="">Like</option>
        <option value="BETWEEN">Between</option>
    </select>
</script>




<script src="/bus/js/layui.js"></script>
<script src="/bus/common.js"></script>
<script src="/bus/genTable.js"></script>
<script>

    //监听性别操作
    form.on('switch(switchTpl-isRequired)', function (obj) {
        //layer.tips(this.value + ' ' + this.name + '：' + obj.elem.checked, obj.othis);
        var value = obj.elem.checked == true ? "1" : "0";
        var datax = "{\"columnId\":" + this.value + ",\"" + this.name + "\"" + ":\"" + value + "\"}";
        datax=JSON.parse(datax);
        commonUtil.sendRequest("PUT", datax,   "/gentable/updateGTC/" + this.value);
    });

    form.on('select(dictType)', function (obj) {
        var elem = $(obj.elem);
        var fieldName = elem.attr('name');
        var trElem = elem.parents('tr');
        //var tableData = table.cache['gtlist'];
        // 更新到表格的缓存数据中，才能在获得选中行等等其他的方法中得到更新之后的值
        //tableData[trElem.data('index')][elem.attr('name')] = data.value;
        var tableData = table.cache['testReload'];
        tableData[trElem.data('index')][elem.attr('name')] = $("#dictTypeData").val();
        var columnId = tableData[trElem.data('index')]['columnId'];
        var selectValue = elem.val();
        var datax = "{\"columnId\":" + columnId + ",\"" + fieldName + "\"" + ":\"" + selectValue + "\"}";
        datax=JSON.parse(datax);
        commonUtil.sendRequest("PUT", datax, "/gentable/updateGTC/" + columnId);
    });

</script>
</body>
</html>
